import {defHttp} from '/@/utils/http/axios';

enum Api {
  businessAudit       = '/report/businessAudit',
  businessEfficient   = '/report/businessEfficient',
  businessCooperator  = '/report/businessCooperator',
  businessCustomer    = '/report/businessCustomer',
  businessCustomerRs  = '/report/businessCustomerRs',
  businessCustomerSkr = '/report/businessCustomerSkr',

  //导入导出
  businessCustomerExportXls = '/businessCustomer/exportXls',
  businessCooperatorExportXls = '/businessCooperator/exportXls',

}

/**
 * 订单统计
 * @param params
 */
export const businessEfficient = async (params) =>  {
  let result = await defHttp.get({url: Api.businessEfficient, params});
  return result.map(item => {
    if (item.hasChildren === 'true') {
      return { ...item, children: [] }
    } else {
      return item
    }
  })
}

/**
 * 状态统计
 * @param params
 */
export const businessAudit = async (params) =>  {
  let result = await defHttp.get({url: Api.businessAudit, params});
  return result.map(item => {
    if (item.hasChildren === 'true') {
      return { ...item, children: [] }
    } else {
      return item
    }
  })
}

/**
 * 导出 -- 收款统计
 * @param params
 */
export const businessCustomerExportUrl = Api.businessCustomerExportXls;

/**
 * 导出 -- 付款统计
 */
export const businessCooperatorExportUrl = Api.businessCooperatorExportXls;


